package com.example.main

import android.graphics.Bitmap
import android.view.KeyEvent
import com.tencent.smtt.sdk.WebView
import com.tencent.smtt.sdk.WebViewClient
//控制H5页面加载生命周期
class X5WebViewClient:WebViewClient() {


    /**
     * 页面开始加载
     */
    override fun onPageStarted(web: WebView?, url: String?, p2: Bitmap?) {
        super.onPageStarted(web, url, p2)
    }

    /**
     * 页面加载完成
     */
    override fun onPageFinished(web: WebView?, p1: String?) {
        super.onPageFinished(web, p1)
    }

    /**
     * H5页面中键盘事件
     */
    override fun shouldOverrideKeyEvent(web: WebView?, p1: KeyEvent?): Boolean {
        return super.shouldOverrideKeyEvent(web, p1)
    }

    /**
     * 拦截H5页面中URL加载
     */
    override fun shouldOverrideUrlLoading(web: WebView?, url: String?): Boolean {
        web?.loadUrl(url)
        return true
    }


}